package com.newtouch.bxzs.database.synchronize.controller;

import com.newtouch.bxzs.database.synchronize.batch.BatchJobStartFactoty;
import com.newtouch.bxzs.database.synchronize.batch.job.SynchronizeJob;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据同步控制类
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/2/25 10:02</td>
 * <td>yuanjie</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "同步数据控制类")
@RestController
@RequestMapping("syncController")
public class SyncController {

    /**
     * 静态变量：系统日志
     */
    private static final Log logger = LogFactory.getLog(SyncController.class);

    @Autowired
    private BatchJobStartFactoty batchJobStartFactoty;

    @Autowired
    private SynchronizeJob synchronizeJob;

    @ApiOperation("开启客户信息同步")
    @GetMapping("/synchronizedCustomer")
    public void synchronizedCustomer(){
        logger.info("batchController:同步客户数据");
        batchJobStartFactoty.startJob(synchronizeJob.synchronizeCustomerJob());
    }

    @ApiOperation("开启机构信息同步")
    @GetMapping("/synchronizedOrganization")
    public void synchronizedOrganization(){
        logger.info("batchController:同步机构数据");
        batchJobStartFactoty.startJob(synchronizeJob.synchronizeOrganJob());
       
    }

    @ApiOperation("开启用户信息同步")
    @GetMapping("/synchronizedUser")
    public void synchronizedUser(){
        logger.info("batchController:同步用户数据");
        batchJobStartFactoty.startJob(synchronizeJob.synchronizeUserJob());
       
    }

    @ApiOperation("开启业绩信息同步")
    @GetMapping("/synchronizedAchievement")
    public void synchronizedAchievement(){
        logger.info("batchController:同步业绩数据");
        batchJobStartFactoty.startJob(synchronizeJob.syncchronizeAchievementJob());
       
    }

    @ApiOperation("开启收入信息同步")
    @GetMapping("/synchronizedIncome")
    public void synchronizedIncome(){
        logger.info("batchController:同步收入数据");
        batchJobStartFactoty.startJob(synchronizeJob.synchronizeIncomeJob());
       
    }

    @ApiOperation("开启产品信息同步")
    @GetMapping("/synchronizedProduct")
    public void synchronizedProduct(){
        logger.info("batchController:同步产品数据");
        batchJobStartFactoty.startJob(synchronizeJob.syncchronizeProductJob());
       
    }
    
}
